import {defineConfig, loadEnv} from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import {myAutoImport, myAutoComponents} from "./conf/vite.auto_import.config";
import local_proxy from './conf/local_proxy.js'

export default defineConfig(({command, mode}) => {
    const config = {};
    const env = loadEnv(mode, process.cwd());
    config.plugins = [
        vue(),
        myAutoImport,
        myAutoComponents
    ];
    config.base = "./";
    config.resolve = {
        alias: {
            "~": path.resolve(__dirname, "./"),
            "@": path.resolve(__dirname, "src")
        }
    };
    config.build = {
        sourcemap: false,
        chunkSizeWarningLimit: 15000,
        // rollupOptions: {
        //   output: {
        //   }
        // }
    };
    config.server = {
        host: true,
        port: 9809,
        proxy: local_proxy[env.VITE_APP_RUN_NAME],
        open: false,
        // hmr: {
        //   overlay: false // 禁用错误覆盖层
        // }
    };
    return config;
});
